#!/usr/bin/env python3
# coding:utf-8

from loguru import logger

logger.add('/tmp/log/runtime.log',rotation="50 KB",retention=2, compression='gz')
count=2000
while count>0:
    logger.debug("this is a debug {}".format(count))
    count -= 1

logger.debug('end')

# 测试结果
# du -sh /tmp/log/*
# 4.0K    runtime_2023-12-26_13-33-19_020612.log.tar.gz
# 4.0K    runtime_2023-12-26_13-33-19_064375.log.tar.gz
# 4.0K    runtime_2023-12-26_13-33-19_107073.log.tar.gz
# 12K     runtime_2023-12-26_13-33-19_208407.log